public class Semaphore
{
	int initialValue;

	public Semaphore( int initial )
	{
		this.initialValue = initial;
	}

	public synchronized void up()
	{
		initialValue++;
			this.notify();
	}

	public synchronized void down()
	{
		while( initialValue == 0 )
		{
			try
			{
				this.wait();
			} catch( InterruptedException e )
			{
				e.printStackTrace();
			}
		}
		initialValue--;
	}
	
	
}
